#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\System.Windows.Forms.Primitives.dll"
#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\System.Windows.Forms.dll"
#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\System.Drawing.Common.dll"
#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\Microsoft.Win32.SystemEvents.dll"
#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\System.Windows.Extensions.dll"
#r "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.17\\Accessibility.dll"

//123

// dotnet --list-runtimes
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

Thread t = new Thread(() =>
{
    var form = new Form
    {
        Text = "Hello WinForms CSX",
        Size = new Size(400, 300)
    };

    var button = new Button
    {
        Text = "Click Me",
        Location = new Point(150, 100),
        Size = new Size(100, 40)
    };
    button.Click += (s, e) => MessageBox.Show("Button Clicked!");
    
    form.Controls.Add(button);

    // 使用 ApplicationContext 包装 Form
    var context = new ApplicationContext(form);
    Application.Run(context);

});

t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
